﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using MyBet.Web;
using MyBet.Helpers;
using System.Windows.Media.Imaging;

namespace MyBet.Class
{
    public class EventGUI 
    {

        

        private EventServiceReference.EventObject _evt;
        private string _displayName;

        public EventServiceReference.EventObject GetEvent
        {
            get { return _evt; }
        }

        public string DisplayName
        {
            get { return _displayName; }
            set { _displayName = value; }
        }

        public string CloseDateText
        {
            get { return GetEvent._closeDate.ToShortDateString() ; }
        }

        public string EventName
        {
            get { return String.Format("{0} {1}", LangHelper.GetString("DayLabel").Trim(), GetEvent._dayNumber); }
        }

        public string EventShortName
        {
            get { return String.Format("#{0}", GetEvent._dayNumber); }
        }

        public BitmapImage EventImage
        {
            get { return ImageUtil.byteArrayToImage(App.ChampionshipsCache[GetEvent._championshipId].Image); }
        }

        public EventGUI(EventServiceReference.EventObject evt)
        {
            _evt = evt;
        }

        public override string ToString()
        {
            return DisplayName;
        }

    }


    public class EventRankGUI
    {
        public enum RankType { General, Average, SpecificDay } ;

        private GetRanksSvc.EventObject _evt;
        private string _displayName;
        private RankType _type;
        private int currentEventId;

        public int CurrentEventId
        {
            get { return currentEventId; }
            set { currentEventId = value; }
        }

        public RankType Type
        {
            get { return _type; }
            set { _type = value; }
        }

        public GetRanksSvc.EventObject GetEvent
        {
            get { return _evt; }
        }

        public string DisplayName
        {
            get { return _displayName; }
            set { _displayName = value; }
        }

        public string CloseDateText
        {
            get { return GetEvent._closeDate.ToShortDateString(); }
        }

        public string EventName
        {
            get { return String.Format("{0} {1}", LangHelper.GetString("DayLabel").Trim(), GetEvent._dayNumber); }
        }

        public string EventShortName
        {
            get { return String.Format("#{0}", GetEvent._dayNumber); }
        }

        public BitmapImage EventImage
        {
            get { return ImageUtil.byteArrayToImage(App.ChampionshipsCache[GetEvent._championshipId].Image); }
        }

        public EventRankGUI(GetRanksSvc.EventObject evt)
        {
            _evt = evt;
            Type = RankType.SpecificDay;
            DisplayName = EventName;
        }

        public EventRankGUI(RankType rankType)
        {
            _evt = null;
            Type = rankType;

            switch (rankType)
            {
                case RankType.General:
                    DisplayName = LangHelper.GetString("GeneralRank").Trim();
                    break;
                case RankType.Average:
                    DisplayName = LangHelper.GetString("AverageRank").Trim();
                    break;
            }
        }

        public override string ToString()
        {
            return DisplayName;
        }

    }

}
